dprime <- function(hit,fa) {
  qnorm(hit) - qnorm(fa)
}

dprime2AFC <- function(hit,fa) {
  (1/sqrt(2))*(qnorm(hit) - qnorm(fa))
}

beta <- function(hit,fa) {
  zhr <- qnorm(hit)
  zfar <- qnorm(fa)
  exp(-zhr*zhr/2+zfar*zfar/2)
}

aprime <- function(hit,fa) {
  a <- 1/2+((hit+fa)*(1+hit-fa) / (4*hit*(1-fa)))
  b <- 1/2-((fa-hit)*(1+fa-hit) / (4*fa*(1-hit)))
  a[fa>hit] <- b[fa>hit] #trick to handle the two cases fa>hit and fa>hit without loop
  a[fa==hit] <- .5
  a
}

bppd <- function(hit,fa) {
  ((1-hit)*(1-fa)-hit*fa) / ((1-hit)*(1-fa)+hit*fa)
}